<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>websocket test</title>

    <script>
        function func1(id,str) {
            var x=document.getElementById(id);
            x.innerHTML=str;
        }
        function disconnect(){
            ws.send("0712");
        }
        function connect(){
            var str=document.getElementById("t_1");
            ws=new WebSocket(str.value);
            ws.onopen=function(evt){
                func1("flag","连接成功")
            };
            ws.onerror=function (evt) {
                func1("flag","未知错误");
            };
            ws.onclose=function (evt) {
                func1("flag","服务端断开");
            };
            ws.onmessage=function (evt) {
                var x=document.getElementById("ta_r");
                x.value= x.value+evt.data;
            };
        }
        function senddat() {
            var str=document.getElementById("ta_s").value;
            ws.send(str);
        }

    </script>

    <style>
        body{
           background-color: #008cba;
        }
        button{
              font-size: 20px;
        }
        .d_left{
            float: left;
            padding-left: 20px;
            padding-top: 50px;
        }
        .p_1{
            font-size: 20px;
        }
    </style>

</head>
<body>

<br/>
服务端：<input id="t_1" type="text" value="ws://0.0.0.0:port" />
<button type="button" onclick="connect()">连接</button>
<button type="button" onclick="disconnect()">断开</button>
<p  id="flag" class="p_1" align="center">连接已断开</p>

<div class="d_left">
    接收到服务端消息:
    <p>
        <textarea readonly name="recv" id="ta_r" cols="70" rows="30"></textarea>
    </p>

</div>
<div class="d_left">    <!--浮动属性-->
    发送到服务端的内容：
    <p>
        <textarea  name="send" id="ta_s" cols="50" rows="20"></textarea>
    </p >
    <button type="button" onclick="senddat()">发送</button>


</div>
<p>
    <!--

 想吃 想爱 想变成天的上忽明忽暗的云
逼自己做的19件难事：做完会被自己惊呆(双语)


1、You have to make the call you’re afraid to make。
你得去打那些你不敢打的电话。

2、You have to get up earlier than you want to get up。
你得在你想赖床的时候强迫自己早起。

3、You have to give more than you get in return right away。
你得付出比你当下获得的回报更多。

4、You have to care more about others than they care about you。
你得比别人在乎你更在乎他们。

5、You have to fight when you are already injured, bloody, and sore。
哪怕你已经受伤、鲜血淋漓和疼痛难忍，你还是得继续奋斗。

6、You have to feel unsure and insecure when playing it safe seems smarter。
你得去体会所有不确定和不安全，虽然谨慎求稳会是你当下更聪明的选择。

7、You have to lead when no one else is following you yet。
你得学会领导，哪怕还没有任何人在跟随你。

8、You have to invest in yourself even though no one else is。
就算别人不会，你也得投资自己。

9、You have to look like a fool while you’re looking for answers you don’t have。
有时候你得看起来像个傻子，因为你要去追寻那些你没有的答案。

10、You have to grind out the details when it’s easier to shrug them off。
你得死抠细节，虽然放过它们会更容易。

11、You have to deliver results when making excuses is an option。
你得展现出成果，虽然你也可以选择找借口。

12、You have to search for your own explanations even when you’re told to accept the “facts。”
就算有人告诉你要接受那些“事实”，你也得去寻找你自己的解释。

13、You have to make mistakes and look like an idiot。
你得犯错，让你自己看起来跟个傻子一样。

14、You have to try and fail and try again。
你得经历努力失败再努力的过程。

15、You have to run faster even though you’re out of breath。
就算你已经上气不接下气，你还得跑得再快一些。

16、You have to be kind to people who have been cruel to you。
你得友好对待那些残忍对你的人。

17、You have to meet deadlines that are unreasonable。
你得在那些完全不合理的最后期限前完成任务。

18、You have to be accountable for your actions even when things go wrong。
就算出了差错，你也得对自己的行为负责。

19、You have to keep moving towards where you want to be no matter what’s in front of you。
不管你的前面有什么，你也得一直朝着你想要到达的目的地前进。

You have to do the hard things. The things that no one else is doing. The things that scare you. The things that make you wonder how much longer you can hold on。
想成功你就得去这些难事，那些别人不做的事情，那些让你害怕的事情，那些会让想自己到底还能坚持多久的事情。

Those are the things that define you. Those are the things that make the difference between living a life of mediocrity or outrageous success。
正是这些难事定义你，正是这些难事区别着平庸和非凡成功两种不同的生活方式。

The hard things are the easiest things to avoid. To excuse away. To pretend like they don’t apply to you。
遇到这些难事，我们最容易采取的行动是避开，是用借口逃开，是假装它们不适合你。

The simple truth about how ordinary people accomplish outrageous feats of success is that they do the hard things that smarter, wealthier, more qualified people don’t have the courage — or desperation — to do。
很简单的事实：普通人是如何取得非凡成就的？他们会做这些难事，这些更聪明、更富有、更有资格的人没有勇气或无法不顾一切拼命去做的事情。

Do the hard things. You might be surprised at how amazing you really are。
去做这些难事吧，你会为自己到底有多棒而感到惊讶的。逼自己做的19件难事：做完会被自己惊呆(双语)

-->

</p>

</body>
</html>


